#include "helper.h"

#include <cstdarg>

std::vector<std::string> split_string
	(std::string const& s, char const* const separators)
{
	std::vector<std::string> result;
	for (std::string::size_type pos = 0, endpos;
		(pos = s.find_first_not_of(separators, pos)) != std::string::npos;
			pos = endpos)
	{
		endpos = s.find_first_of(separators, pos);
		result.push_back(s.substr(pos, endpos - pos));
	}
	return result;
}

void remove_spaces(std::string& s)
{
	while (s[0] == ' ' or s[0] == '\t' or s[0] == '\n') s.erase(0, 1);
	
	while (*s.rbegin() == ' ' or *s.rbegin() == '\t' or *s.rbegin() == '\n')
		s.erase(s.size() - 1, 1);
}

bool is_printable(SDK_keysym k)
{
	return 
		(k.sym == SDLK_TAB) ||
		((k.sym >= SDLK_SPACE) && (k.sym <= SDLK_z)) ||
		((k.sym >= SDLK_WORLD_0) && (k.sym <= SDLK_WORLD_95)) ||
		((k.sym >= SDLK_KP0) && (k.sym <= SDLK_KP_EQUALS));
}
